import {director, Node} from 'cc';
import {PrefabManager} from "db://assets/scripts/common/PrefabManager";
import {PrefabDefs} from "db://assets/scripts/defs/PrefabDefs";
import {TipsFramePrefUI} from "db://assets/scripts/modules/common/TipsFramePrefUI";

/**
 * 提示界面管理器
 */
export class TipsFrameManager {

    /**
     * 显示提示框
     * @param title 标题
     * @param context 内容
     * @param callback 回调函数
     */
    public static showTipsFrame(title: string, context: string, callback: Function): void {
        let node: Node = PrefabManager.instantiate(PrefabDefs.TipsFramePref, director.getScene().getChildByName("Canvas"));
        // 设置标题和内容
        let tipsFramePrefUI = node.getComponent(TipsFramePrefUI);
        tipsFramePrefUI.setTitle(title);
        tipsFramePrefUI.setContext(context);
        // 设置按钮回调
        tipsFramePrefUI.setBtnCallback(callback);
    }

}


